#include "dlgstreetedit.h"
#include "ui_dlgstreetedit.h"

DlgStreetEdit::DlgStreetEdit(QWidget *parent) :
    QDialog(parent),
    DbmsEditor(),
    ui(new Ui::DlgStreetEdit)
{
    ui->setupUi(this);
    connect(ui->btn_ok, SIGNAL(clicked()), this, SLOT(accept()));
    connect(ui->btn_cancel, SIGNAL(clicked()), this , SLOT(reject()));

}

DlgStreetEdit::~DlgStreetEdit()
{
    delete ui;
}

void DlgStreetEdit::setup_connection()
{
    connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(data_changed()));
    connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(data_changed()));
}

void DlgStreetEdit::data_to_form()
{
    ui->comboBox->addItems(mp_dbms->get_street_types(true));
    if(mqh_data.isEmpty()) return;
    ui->lineEdit->setText(mqh_data.value(FLD_STDB_NAME).toString());
    ui->comboBox->setCurrentIndex(mqh_data.value(FLD_STDB_TYPE).toInt());
}

void DlgStreetEdit::form_to_data()
{
    mqh_data[FLD_STDB_NAME] =ui->lineEdit->text().toUpper().trimmed();
    mqh_data[FLD_STDB_TYPE] = (int) ui->comboBox->currentIndex();
}


